
const person = {
  name: 'tom',
  say1: function () {
    console.log(`hi,my name is ${this.name}`);//this指向内部
  },
  say2: () => {
    console.log(`hi,my name is ${this.name}`);//因为箭头函数不会改变this,this指向外部全局
  },
  sayAsync1: function () {
    setTimeout(function () {
      console.log(`hi,my name is ${this.name}`);//这里this指向外部全局
    }, 0)
  },
  sayAsync2: function () {
    setTimeout(() => {
      console.log(`hi,my name is ${this.name}`);//this指向内部
    }, 0)
  }
}

person.say1();
person.say2();
person.sayAsync1();
person.sayAsync2();